﻿#include "application.h"

#include "cppfont.h"
#include "socket.h"
#include "startwidget.h"
#include "loginwidget.h"
#include "mainwidget.h"

Application::Application() {
    m_state = E_APP_STATE_START;
}

void Application::init() {
    CppFont::cppFontInit();
    Socket *socket = Socket::getSocket();
    socket->initSocket();
}

int Application::exec() {
    init();
    while(1) {
        switch (m_state) {
            case E_APP_STATE_NONE:
                break;
            case E_APP_STATE_START: { //进入开始画面的状态
                StartWidget w;
                w.show();
            }
            m_state = E_APP_STATE_LOGIN;
            break;
            case E_APP_STATE_LOGIN: { //进入登录界面的状态
                LoginWidget w;
                w.show();
            }
            m_state = E_APP_STATE_MAIN;
            break;
            case E_APP_STATE_MAIN: { //进入主界面的状态
                MainWidget w;
                w.show();
            }
            m_state = E_APP_STATE_LOGIN;
            break;
        }
    }
}
